<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="../dist/mchart.js"></script>
    <style>
        #first {
            width: 900px;
            height: 300px;
            background-color: antiquewhite;
        }
    </style>
</head>
<body>
<div id="first">

</div>
<button onclick="updateSource()">更新数据</button>
<script>
    var data = [23, 12];

    var chart = new mchart.chart({
        style: {
            sources: [
                {
                    id: 'source-first',
                    type: 'array',
                    data: data
                }
            ],
            charts: [
                {
                    id: 'first',
                    type: 'line',
                    sourceId: 'source-first'
                }
            ]
        }
    });

    function updateSource() {
        data.push(Math.random() * 40);
        chart.updateSource('source-first', data);
    }

</script>
</body>
</html>